<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title><?php echo ((isset($title) && ($title !== ""))?($title):get_system_config("system_name")); ?></title>
		<link href="/Public/Ins/css/bootstrap.min.css" rel="stylesheet">
		<link href="/Public/Ins/font-awesome/css/font-awesome.css" rel="stylesheet">
		<link href="/Public/Ins/css/animate.css" rel="stylesheet">
		<link href="/Public/Ins/css/plugins/toastr/toastr.min.css" rel="stylesheet">
		<link href="/Public/Ins/css/plugins/gritter/jquery.gritter.css" />
		<?php if(!empty($plugin["jquery-ui"])): ?><link rel="stylesheet" href="/Public/Ins/css/plugins/jQueryUI/jquery-ui-1.10.4.custom.min.css" />
	<link rel="stylesheet" href="/Public/Ins/css/plugins/nouslider/jquery.nouislider.css" rel="stylesheet"><?php endif; ?>

	<link rel="stylesheet" href="/Public/Ins/css/plugins/date-time/bootstrap-datetimepicker.css" />


		<link href="/Public/Ins/css/style.css" rel="stylesheet">
		<link href="/Public/Ins/css/xiaowei.css" rel="stylesheet">
		<link href="/Public/Ins/css/nprogress.css" rel="stylesheet">
		<script src="/Public/Ins/js/nprogress.js"></script>
		<link rel="stylesheet" href="/Public/Ins/css/plugins/nouslider/jquery.nouislider.css" rel="stylesheet"><link rel="stylesheet" href="/Public/Ins/css/plugins/date-time/bootstrap-datetimepicker.css" />
		
	</head>
	<script type="text/javascript">
	var upload_url = "<?php echo U('upload');?>";
	var del_url = "<?php echo U('del_file');?>";
	var app_path = "";
	var cookie_prefix = "<?php echo C('COOKIE_PREFIX');?>";
	var link_select = "<?php echo U('Popup/link_select');?>";
	
</script>

	<body class="<?php echo (CONTROLLER_NAME); ?>">
		<div class="shade"></div>
		<div class="form-group hidden" id="img_upload_container">
			<div id="img_upload">上传</div>
		</div>
		<nav class="navbar navbar-default row" role="navigation" id="top_menu">
			<!-- Brand and toggle get grouped for better mobile display -->
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-6">
					<span class="sr-only">Toggle navigation</span>
					<i class="fa fa-bars fa-lg"></i>
				</button>
				<div class="hidden-xs">
					&nbsp;
				</div>
				<a href="<?php echo U('index/index');?>" class="navbar-brand"><?php echo get_system_config("system_name");?></a>
			</div>
			<!-- Collect the nav links, forms, and other content for toggling -->
			<div class="collapse navbar-collapse" id="navbar-collapse-6">
				<ul class="nav navbar-nav navbar-right">
					<?php if(is_array($top_menu)): foreach($top_menu as $key=>$top_menu_vo): ?><a class="nav-app" href="#" url="<?php echo (get_nav_url($top_menu_vo['url'])); ?>" node="<?php echo ($top_menu_vo["id"]); ?>" onclick="click_top_menu(this)" ><i class="<?php echo ($top_menu_vo["icon"]); ?>"></i><?php echo ($top_menu_vo["name"]); ?>
						<?php if(!empty($badge_count[$top_menu_vo['id']])){ $html=''; $html='<span class="label label-danger">'.$badge_count[$top_menu_vo['id']].'</span>'; echo $html; } ?></a><?php endforeach; endif; ?>
					<a class="nav-app btn-danger" href="<?php echo U('public/logout');?>"><i class="fa fa-sign-out"></i>退出</a>
				</ul>
			</div><!-- /.navbar-collapse -->
		</nav>
		<div id="wrapper">
			<div class="sidebar navbar-static-side" id="sidebar">
				<div id="user_info" class="text-center hidden-xs"  >
					<span >当前用户：<?php echo (session('user_name')); ?></span>
				</div>
				<div id="nav_head" class="text-center" onclick="toggle_left_menu()">
					<span class="menu-text"><?php echo ($top_menu_name); ?></span>
					<b id="left_menu_icon" class="fa fa-angle-down pull-right"></b>
				</div>
				<?php echo W('Sidebar/left',array('tree'=>$left_menu,'badge_count'=>$badge_count));?>
			</div>
			<div id="page-wrapper" class="gray-bg">
				<div class="row wrapper border-bottom gray-bg">
					<div class="breadcrumbs" id="breadcrumbs">
						<ul class="breadcrumb">
							<li>
								<i class="fa fa-home home-icon"></i>
								<a href="/">Home</a>
							</li>
							<li>
								<?php echo ($top_menu_name); ?>
							</li>
						</ul><!-- .breadcrumb -->
					</div>
				</div>
				<div class="wrapper wrapper-content">
					
		<?php echo W('PageHeader/simple',array('name'=>'请假','search'=>'N'));?>
	<div class="operate panel panel-default">
		<div class="panel-body">
			<div class="pull-left">
				<a onclick="go_return_url();" class="btn btn-sm btn-primary">返回</a>
				<?php if(($flow_type["is_lock"]) == "0"): ?><a onclick="popup_confirm();"  class="btn btn-sm btn-primary">选择审批流程</a><?php endif; ?>
			</div>
			<div class="pull-right">

				<a onclick="save(20);"  id="post" class="btn btn-sm btn-primary">提交申请</a>
			</div>
		</div>
	</div>
	<form method='post' id="form_data" name="form_data" enctype="multipart/form-data" class="well form-horizontal">
		<input type="hidden" id="id" name="id" value="<?php echo $leave['id']?>" >
	    <input type="hidden" id="confirm" name="confirm" value="<?php echo $leave['confirm']?>" >
		<input type="hidden" id="confirm_name" name="confirm_name" value='<?php echo $leave['confirm_name']?>' >

		<div class="form-group">
			<label class="col-sm-2 control-label" for="name">请假类型：</label>			
			<div class="col-sm-10">
				<select class="form-control" id='type' name = 'type'>
				<?php foreach($typelist as $type){?>
				<option  <?php if($type['key']==$leave['type']){echo "selected='selected'";}?> value="<?php echo $type['key']?>"><?php echo $type['value']?></option>
				<?php };?>
				</select>
			</div>
		</div>
		<div class="form-group col-xs-12">
			<label class="col-sm-2 control-label" for="type">审批步骤：</label>
			<div class="col-sm-10">
				<div id="confirm_wrap" class="inputbox">
					<a class="pull-right btn btn-link text-center" onclick="popup_flow();"> <i class="fa fa-user"></i> </a>
					<div class="wrap" >
						<span class="address_list"><?php echo $leave['confirm_name']?></span>
						<span class="text" >
							<input class="letter" type="text"  >
							
						</span>
						
					</div>
					<div class="search dropdown ">
						<ul class="dropdown-menu"></ul>
					</div>
				</div>
			</div>
		</div>
		
	
		

			<div class="form-group">
			<label class="col-sm-2 control-label" for="name">请假时间：</label>			
			<div class="col-sm-10">
			<input type="text" value="<?php echo date('Y-m-d H:i:s',$leave['start_time'])?>" style='width: 200px;float: left'  id="start_time" name="start_time" readonly="readonly" class="form-control input-date-ymd-h changge-h" check="require" msg="请输入开始日期">
			<span style="float: left;;margin: 10px">至</span>
			<input value="<?php echo date('Y-m-d H:i:s',$leave['end_time'])?>" style='width: 200px;float: left' type="text" id="end_time" name="end_time" readonly="readonly" class="form-control input-date-ymd-h changge-h" check="require" msg="请输入结束日期" readonly="readonly">					
			</div>
		</div>
		
		
		<div class="form-group">
			<label class="col-sm-2 control-label" for="name">复工时间：</label>			
			<div class="col-sm-10">
			<input value="<?php echo date('Y-m-d H:i:s',$leave['comeback_time'])?>"  type="text" style='width: 200px;float: left'  id="comeback_time" name=" comeback_time" readonly="readonly" class="form-control input-date-ymd-h" check="require" msg="请输入复工日期">				
			</div>
		</div>
		
			<div class="form-group">
			<label class="col-sm-2 control-label" for="name">总时(小时)：</label>			
			<div class="col-sm-10">
				<input class="form-control" type="text" id="count_time_h" value="<?php echo $leave['count_time_h']?>" name="count_time_h">
			</div>
		</div>
		
		<div class="form-group" id='deductions_day_div'>
			<label class="col-sm-2 control-label" for="name">扣除工资(天)：</label>			
			<div class="col-sm-10">
				<input class="form-control" type="text" id="deductions_day" name="deductions_day"  value="<?php echo $leave['deductions_day']?>" >
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-2 control-label" for="name">请假事由：</label>			
			<div class="col-sm-10">
				<textarea  class="editor" id="content" name="content" style="width:100%;height:300px;"><?php echo $leave['udf_data']?></textarea>
			</div>
		</div>
			
		

	</form>

				</div>
			</div>
		</div>
		<iframe src="<?php echo U('push/client');?>" class="push" id="push"></iframe>
		<!-- Mainly scripts -->
		<script src="/Public/Ins/js/jquery-2.1.1.js"></script>
		<script src="/Public/Ins/js/bootstrap.min.js"></script>
		<script src="/Public/Ins/js/plugins/metisMenu/jquery.metisMenu.js"></script>
		<script src="/Public/Ins/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
		

		<!-- Custom and plugin javascript -->
		<script src="/Public/Ins/js/inspinia.js"></script>
		<script src="/Public/Ins/js/common.js"></script>
		<script src="/Public/Ins/js/plugins/pace/pace.min.js"></script>
		<?php if(!empty($plugin["jquery-ui"])): ?><script src="/Public/Ins/js/plugins/jquery-ui/jquery-ui.min.js"></script>
	<script src="/Public/Ins/js/plugins/nouslider/jquery.nouislider.min.js"></script><?php endif; ?>

	<script src="/Public/Ins/js/plugins/date-time/moment-with-locales.js"></script>
	<script src="/Public/Ins/js/plugins/date-time/bootstrap-datetimepicker.js"></script>


<?php if(!empty($plugin["uploader"])): ?><script type="text/javascript" src="/Public/Ins/js/plugins/plupload/plupload.full.min.js"></script>
	<?php if(empty($plugin["auth"])): ?><script type="text/javascript" src="/Public/Ins/js/plugins/plupload/plupload.setting.js"></script><?php endif; endif; ?>

<?php if(!empty($plugin["editor"])): if(empty($plugin["uploader"])): ?><script type="text/javascript" src="/Public/Ins/js/plugins/plupload/plupload.full.min.js"></script><?php endif; ?>
	<script type="text/javascript" src="/Public/Ins/js/plugins/tinymce/tinymce.min.js"></script>
	<script type="text/javascript" src="/Public/Ins/js/plugins/tinymce/tinymce.setting.js"></script><?php endif; ?>

<?php if(!empty($plugin["baidu_map"])): ?><script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=EE6745c36d96321e90b7015f3de4a4ee"></script><?php endif; ?>

<script src="/Public/Ins/js/plugins/toastr/toastr.min.js"></script>
<script src="/Public/Ins/js/plugins/gritter/jquery.gritter.min.js"></script>
<script src="/Public/Ins/js/plugins/bootbox/bootbox.min.js"></script>

<script type="text/javascript">
	$(document).ready(function() {
		<?php if(!empty($plugin["date"])): ?>$('.input-date').datetimepicker({
			format : 'YYYY-MM-DD',
			locale : 'zh-cn',
			ignoreReadonly : true,
			widgetPositioning : {
				horizontal : 'auto',
				vertical : 'bottom'
			},
		});
		
		$(".input-daterange input").datetimepicker({
			format : "YYYY-MM-DD",
			locale : 'zh-cn',
			showTodayButton : true,
			showClose : true,
			ignoreReadonly : true,
			widgetPositioning : {
				horizontal : 'auto',
				vertical : 'bottom'
			},
		});

		$("#start_date").on("dp.change", function(e) {
			if ($("#end_date").length > 0) {
				$('#end_date').data("DateTimePicker").minDate(e.date);
			}
		});
		
		$("#end_date").on("dp.change", function(e) {
			if ($("#start_date").length > 0) {
				$('#start_date').data("DateTimePicker").maxDate(e.date);
			}
		});

		$(".input-date-time").datetimepicker({
			format : 'YYYY-MM-DD HH:mm',
			locale : 'zh-cn',
			sideBySide : true,
			showTodayButton : true,
			showClose : true,
			ignoreReadonly : true,
			widgetPositioning : {
				horizontal : 'auto',
				vertical : 'bottom'
			},
		});<?php endif; ?>		 
	}); 
</script>
		
<script>
$('#type').change(function(){
	var value = parseInt( $(this).val());
	if(value>0){
		$('#deductions_day_div').hide();
	}else{
		$('#deductions_day_div').show();
	}
	
});
function popup_flow() {
	winopen("<?php echo U('popup/flow');?>",560, 470);
};

$(document).ready(function() {
$('.input-date-ymd-h').datetimepicker({
	format : 'YYYY-MM-DD H:00:00',
	locale : 'zh-cn',
	ignoreReadonly : true,
	widgetPositioning : {
		horizontal : 'auto',
		vertical : 'bottom'
	},
});


});


function save(step) {
	$("#confirm").val("");
	$("#confirm_wrap  span.address_list span").each(function() {
		$("#confirm").val($("#confirm").val() + $(this).attr("data") + '|');
	});

	$("#confirm_name").val("");
	$("#confirm_name").val($("#confirm_wrap span.address_list").html());

	if ($("#comeback_time").val().length < 2) {
		ui_error('请选择复工日期');
		return false;
	}
	$("#step").val(step);
	sendForm("form_data", "<?php echo U('saveleave');?>", "<?php echo U('index');?>");
    var t=5;
	var int=setInterval(function(){
		t--;
		if(t==0){
			$("#post").html("提交申请")
			$("#post").attr("onclick","save(20)");
			 clearInterval(int);

		}else{
		  $("#post").attr("onclick","javascript:alert('不能重复提交！')");
		  $("#post").html("重新提交("+t+")")	
		}
	},1000)
	
}



$('.changge-h1').focus(function(){
	var changeObj = $('.changge-h');
	var v1 = $(changeObj[0]).val();
	var v2 = $(changeObj[1]).val();
	getD(v1,v2);
})

function getD(d1,d2){
	alert(d1+d2);
	var date1=new Date(d1);  //开始时间

	var date2=new Date(d2);    //结束时间
	var date3=date2.getTime()-date1.getTime()  //时间差的毫秒数
	 

	//计算出相差天数
	var days=Math.floor(date3/(24*3600*1000))
	 
	//计算出小时数

	var leave1=date3%(24*3600*1000)    //计算天数后剩余的毫秒数
	var hours=Math.floor(leave1/(3600*1000))

	$('#count_time_h').val(hours);
	
	}
</script>




	</body>
</html>